package br.com.single.publico;

import br.com.single.modelo.estoque.Cdprodut;
import br.com.single.modelo.estoque.Mvfrete;
import br.com.single.modelo.estoque.Mvmovimecompra;
import br.com.single.modelo.financeiro.Cdfluxocaixa;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

@Entity
@Table(schema = "publico",name = "cdfornec")
@RooJavaBean
@RooToString
@RooJpaActiveRecord(versionField = "", table = "cdfornec", schema = "publico")
@RooDbManaged(automaticallyDelete = true)
public class Cdfornec {

	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "codigofornec",columnDefinition="codigonumero")
    private Integer codigofornec;

	public Integer getCodigofornec() {
        return this.codigofornec;
    }

	public void setCodigofornec(Integer id) {
        this.codigofornec = id;
    }

	@OneToMany(mappedBy = "marca")
    private Set<Cdprodut> cdproduts;

	@OneToMany(mappedBy = "ultimoforneccompra")
    private Set<Cdprodut> cdproduts1;

	@OneToMany(mappedBy = "ancorafornec")
    private Set<Cdprodut> cdproduts2;

	@OneToMany(mappedBy = "transp")
    private Set<Mvfrete> mvfretes;

	@OneToMany(mappedBy = "fornec")
    private Set<Mvmovimecompra> mvmovimecompras;

	@OneToMany(mappedBy = "transprepres")
    private Set<Cdrepres> cdrepreses;

	@ManyToOne
    @JoinColumn(name = "fluxocaixa", referencedColumnName = "codigofluxo",columnDefinition="fluxocaixa")
    private Cdfluxocaixa fluxocaixa;

	@ManyToOne
    @JoinColumns({ @JoinColumn(name = "estadofornec", referencedColumnName = "codigoestado",columnDefinition="bpchar"), @JoinColumn(name = "codigocidadefornec", referencedColumnName = "codigocidade",columnDefinition="codigocidade") })
    private Cdcidade cdcidade;

	@ManyToOne
    @JoinColumns({ @JoinColumn(name = "tabelamd", referencedColumnName = "codigotabela",columnDefinition="bpchar"), @JoinColumn(name = "modelodocume", referencedColumnName = "elementabela",columnDefinition="bpchar") })
    private Cditemtabelageneri cditemtabelageneri;

	@ManyToOne
    @JoinColumns({ @JoinColumn(name = "tabelaar", referencedColumnName = "codigotabela",columnDefinition="bpchar"), @JoinColumn(name = "areafornec", referencedColumnName = "elementabela",columnDefinition="classisimple") })
    private Cditemtabelageneri cditemtabelageneri1;

	@ManyToOne
    @JoinColumns({ @JoinColumn(name = "tabelaae", referencedColumnName = "codigotabela",columnDefinition="bpchar"), @JoinColumn(name = "atividfornec", referencedColumnName = "elementabela",columnDefinition="classisimple") })
    private Cditemtabelageneri cditemtabelageneri2;

	@ManyToOne
    @JoinColumns({ @JoinColumn(name = "tabelapo", referencedColumnName = "codigotabela",columnDefinition="bpchar"), @JoinColumn(name = "portefornec", referencedColumnName = "elementabela",columnDefinition="classisimple") })
    private Cditemtabelageneri cditemtabelageneri3;

	@ManyToOne
    @JoinColumns({ @JoinColumn(name = "tabelaf1", referencedColumnName = "codigotabela",columnDefinition="bpchar"), @JoinColumn(name = "tipofornec", referencedColumnName = "elementabela",columnDefinition="classisimple") })
    private Cditemtabelageneri cditemtabelageneri4;

	@ManyToOne
    @JoinColumns({ @JoinColumn(name = "tabelatt", referencedColumnName = "codigotabela",columnDefinition="bpchar"), @JoinColumn(name = "tipotitulo", referencedColumnName = "elementabela",columnDefinition="bpchar") })
    private Cditemtabelageneri cditemtabelageneri5;

	@Column(name = "nomefornec",columnDefinition="nomegrande")
    @NotNull
    private String nomefornec;

	@Column(name = "fantasfornec",columnDefinition="nomereduzi")
    @NotNull
    private String fantasfornec;

	@Column(name = "statusfornec")
    @NotNull
    private Character statusfornec;

	@Column(name = "cnpjfornec",columnDefinition="cnpj")
    private String cnpjfornec;

	@Column(name = "iefornec",columnDefinition="ie")
    private String iefornec;

	@Column(name = "logradfornec",columnDefinition="lograd")
    private String logradfornec;

	@Column(name = "cepfornec",columnDefinition="cep")
    private String cepfornec;

	@Column(name = "bairrofornec",columnDefinition="bairro")
    private String bairrofornec;

	@Column(name = "cidadefornec",columnDefinition="cidade")
    private String cidadefornec;

	@Column(name = "numerologradfornec",columnDefinition="numerolograd")
    private String numerologradfornec;

	@Column(name = "complelogradfornec",columnDefinition="nomereduzi")
    private String complelogradfornec;

	@Column(name = "contatfornec",columnDefinition="contat")
    private String contatfornec;

	@Column(name = "telefofornec",columnDefinition="fone")
    private String telefofornec;

	@Column(name = "telefofornec02",columnDefinition="fone")
    private String telefofornec02;

	@Column(name = "telefofornec03",columnDefinition="fone")
    private String telefofornec03;

	@Column(name = "celulafornec",columnDefinition="fone")
    private String celulafornec;

	@Column(name = "faxfornec",columnDefinition="fone")
    private String faxfornec;

	@Column(name = "emailfornec",columnDefinition="email")
    private String emailfornec;

	@Column(name = "ctbcodigo",columnDefinition="codigocontab")
    private String ctbcodigo;

	@Column(name = "ctbapendi",columnDefinition="apendicontab")
    private String ctbapendi;

	@Column(name = "ctabanco",columnDefinition="nomereduzi")
    private String ctabanco;

	@Column(name = "ctadescribanco",columnDefinition="nomereduzi")
    private String ctadescribanco;

	@Column(name = "ctaagenci",columnDefinition="nomereduzi")
    private String ctaagenci;

	@Column(name = "ctanumero",columnDefinition="nomereduzi")
    private String ctanumero;

	@Column(name = "ctaoperac",columnDefinition="nomereduzi")
    private String ctaoperac;

	@Column(name = "ctaobserv",columnDefinition="nomegrande")
    private String ctaobserv;

	@Column(name = "chaveimport",columnDefinition="nomereduzi")
    private String chaveimport;

	@Column(name = "sitefornec",columnDefinition="email")
    private String sitefornec;

	public Set<Cdprodut> getCdproduts() {
        return cdproduts;
    }

	public void setCdproduts(Set<Cdprodut> cdproduts) {
        this.cdproduts = cdproduts;
    }

	public Set<Cdprodut> getCdproduts1() {
        return cdproduts1;
    }

	public void setCdproduts1(Set<Cdprodut> cdproduts1) {
        this.cdproduts1 = cdproduts1;
    }

	public Set<Cdprodut> getCdproduts2() {
        return cdproduts2;
    }

	public void setCdproduts2(Set<Cdprodut> cdproduts2) {
        this.cdproduts2 = cdproduts2;
    }

	public Set<Mvfrete> getMvfretes() {
        return mvfretes;
    }

	public void setMvfretes(Set<Mvfrete> mvfretes) {
        this.mvfretes = mvfretes;
    }

	public Set<Mvmovimecompra> getMvmovimecompras() {
        return mvmovimecompras;
    }

	public void setMvmovimecompras(Set<Mvmovimecompra> mvmovimecompras) {
        this.mvmovimecompras = mvmovimecompras;
    }

	public Set<Cdrepres> getCdrepreses() {
        return cdrepreses;
    }

	public void setCdrepreses(Set<Cdrepres> cdrepreses) {
        this.cdrepreses = cdrepreses;
    }

	public Cdfluxocaixa getFluxocaixa() {
        return fluxocaixa;
    }

	public void setFluxocaixa(Cdfluxocaixa fluxocaixa) {
        this.fluxocaixa = fluxocaixa;
    }

	public Cdcidade getCdcidade() {
        return cdcidade;
    }

	public void setCdcidade(Cdcidade cdcidade) {
        this.cdcidade = cdcidade;
    }

	public Cditemtabelageneri getCditemtabelageneri() {
        return cditemtabelageneri;
    }

	public void setCditemtabelageneri(Cditemtabelageneri cditemtabelageneri) {
        this.cditemtabelageneri = cditemtabelageneri;
    }

	public Cditemtabelageneri getCditemtabelageneri1() {
        return cditemtabelageneri1;
    }

	public void setCditemtabelageneri1(Cditemtabelageneri cditemtabelageneri1) {
        this.cditemtabelageneri1 = cditemtabelageneri1;
    }

	public Cditemtabelageneri getCditemtabelageneri2() {
        return cditemtabelageneri2;
    }

	public void setCditemtabelageneri2(Cditemtabelageneri cditemtabelageneri2) {
        this.cditemtabelageneri2 = cditemtabelageneri2;
    }

	public Cditemtabelageneri getCditemtabelageneri3() {
        return cditemtabelageneri3;
    }

	public void setCditemtabelageneri3(Cditemtabelageneri cditemtabelageneri3) {
        this.cditemtabelageneri3 = cditemtabelageneri3;
    }

	public Cditemtabelageneri getCditemtabelageneri4() {
        return cditemtabelageneri4;
    }

	public void setCditemtabelageneri4(Cditemtabelageneri cditemtabelageneri4) {
        this.cditemtabelageneri4 = cditemtabelageneri4;
    }

	public Cditemtabelageneri getCditemtabelageneri5() {
        return cditemtabelageneri5;
    }

	public void setCditemtabelageneri5(Cditemtabelageneri cditemtabelageneri5) {
        this.cditemtabelageneri5 = cditemtabelageneri5;
    }

	public String getNomefornec() {
        return nomefornec;
    }

	public void setNomefornec(String nomefornec) {
        this.nomefornec = nomefornec;
    }

	public String getFantasfornec() {
        return fantasfornec;
    }

	public void setFantasfornec(String fantasfornec) {
        this.fantasfornec = fantasfornec;
    }

	public Character getStatusfornec() {
        return statusfornec;
    }

	public void setStatusfornec(Character statusfornec) {
        this.statusfornec = statusfornec;
    }

	public String getCnpjfornec() {
        return cnpjfornec;
    }

	public void setCnpjfornec(String cnpjfornec) {
        this.cnpjfornec = cnpjfornec;
    }

	public String getIefornec() {
        return iefornec;
    }

	public void setIefornec(String iefornec) {
        this.iefornec = iefornec;
    }

	public String getLogradfornec() {
        return logradfornec;
    }

	public void setLogradfornec(String logradfornec) {
        this.logradfornec = logradfornec;
    }

	public String getCepfornec() {
        return cepfornec;
    }

	public void setCepfornec(String cepfornec) {
        this.cepfornec = cepfornec;
    }

	public String getBairrofornec() {
        return bairrofornec;
    }

	public void setBairrofornec(String bairrofornec) {
        this.bairrofornec = bairrofornec;
    }

	public String getCidadefornec() {
        return cidadefornec;
    }

	public void setCidadefornec(String cidadefornec) {
        this.cidadefornec = cidadefornec;
    }

	public String getNumerologradfornec() {
        return numerologradfornec;
    }

	public void setNumerologradfornec(String numerologradfornec) {
        this.numerologradfornec = numerologradfornec;
    }

	public String getComplelogradfornec() {
        return complelogradfornec;
    }

	public void setComplelogradfornec(String complelogradfornec) {
        this.complelogradfornec = complelogradfornec;
    }

	public String getContatfornec() {
        return contatfornec;
    }

	public void setContatfornec(String contatfornec) {
        this.contatfornec = contatfornec;
    }

	public String getTelefofornec() {
        return telefofornec;
    }

	public void setTelefofornec(String telefofornec) {
        this.telefofornec = telefofornec;
    }

	public String getTelefofornec02() {
        return telefofornec02;
    }

	public void setTelefofornec02(String telefofornec02) {
        this.telefofornec02 = telefofornec02;
    }

	public String getTelefofornec03() {
        return telefofornec03;
    }

	public void setTelefofornec03(String telefofornec03) {
        this.telefofornec03 = telefofornec03;
    }

	public String getCelulafornec() {
        return celulafornec;
    }

	public void setCelulafornec(String celulafornec) {
        this.celulafornec = celulafornec;
    }

	public String getFaxfornec() {
        return faxfornec;
    }

	public void setFaxfornec(String faxfornec) {
        this.faxfornec = faxfornec;
    }

	public String getEmailfornec() {
        return emailfornec;
    }

	public void setEmailfornec(String emailfornec) {
        this.emailfornec = emailfornec;
    }

	public String getCtbcodigo() {
        return ctbcodigo;
    }

	public void setCtbcodigo(String ctbcodigo) {
        this.ctbcodigo = ctbcodigo;
    }

	public String getCtbapendi() {
        return ctbapendi;
    }

	public void setCtbapendi(String ctbapendi) {
        this.ctbapendi = ctbapendi;
    }

	public String getCtabanco() {
        return ctabanco;
    }

	public void setCtabanco(String ctabanco) {
        this.ctabanco = ctabanco;
    }

	public String getCtadescribanco() {
        return ctadescribanco;
    }

	public void setCtadescribanco(String ctadescribanco) {
        this.ctadescribanco = ctadescribanco;
    }

	public String getCtaagenci() {
        return ctaagenci;
    }

	public void setCtaagenci(String ctaagenci) {
        this.ctaagenci = ctaagenci;
    }

	public String getCtanumero() {
        return ctanumero;
    }

	public void setCtanumero(String ctanumero) {
        this.ctanumero = ctanumero;
    }

	public String getCtaoperac() {
        return ctaoperac;
    }

	public void setCtaoperac(String ctaoperac) {
        this.ctaoperac = ctaoperac;
    }

	public String getCtaobserv() {
        return ctaobserv;
    }

	public void setCtaobserv(String ctaobserv) {
        this.ctaobserv = ctaobserv;
    }

	public String getChaveimport() {
        return chaveimport;
    }

	public void setChaveimport(String chaveimport) {
        this.chaveimport = chaveimport;
    }

	public String getSitefornec() {
        return sitefornec;
    }

	public void setSitefornec(String sitefornec) {
        this.sitefornec = sitefornec;
    }

	
	
	@PersistenceContext
    transient EntityManager entityManager;

	public static final EntityManager entityManager() {
        EntityManager em = new Cdfornec().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	public static long countCdfornecs() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Cdfornec o", Long.class).getSingleResult();
    }

	public static List<Cdfornec> findAllCdfornecs() {
        return entityManager().createQuery("SELECT o FROM Cdfornec o", Cdfornec.class).getResultList();
    }

	public static Cdfornec findCdfornec(Integer codigofornec) {
        if (codigofornec == null || codigofornec == 0) return null;
        return entityManager().find(Cdfornec.class, codigofornec);
    }

	public static List<Cdfornec> findCdfornecEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Cdfornec o", Cdfornec.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

	@Transactional
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	@Transactional
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Cdfornec attached = Cdfornec.findCdfornec(this.codigofornec);
            this.entityManager.remove(attached);
        }
    }

	@Transactional
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	@Transactional
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	@Transactional
    public Cdfornec merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Cdfornec merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }
}
